a = input()
list1 = []
arg = []
for i in a:
    if i in '()[]{}<>':
        list1.append(i)
if len(list1) % 2 == 0:
    for i in range(len(list1)):
        if list1[i] == '(':
            arg.append(1)
        elif list1[i] == '[':
            arg.append(2)
        elif list1[i] == '{':
            arg.append(3)
        elif list1[i] == '<':
            arg.append(4)
        elif list1[i] == ')' and arg[-1] == 1:
            arg.pop()
        elif list1[i] == ']' and arg[-1] == 2:
            arg.pop()
        elif list1[i] == '}' and arg[-1] == 3:
            arg.pop()
        elif list1[i] == '>' and arg[-1] == 4:
            arg.pop()
    if arg:
        print('False')
    else:
        print('True')
else:
    print('False')